/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 08 - 17
 * Time: 21:08
 */
//牛客 删除链表中重复的结点
public class Solution2 {
        public ListNode deleteDuplication(ListNode pHead) {
            if(pHead == null) return null;
            ListNode node = new ListNode(0);
            node.next = pHead;
            ListNode cur = node;
            while(cur.next != null && cur.next.next != null) {
                if(cur.next.val == cur.next.next.val) {
                    int tmp = cur.next.val;
                    while(cur.next != null && cur.next.val == tmp) {//重点：删除连续的重复的那一段的节点
                        cur.next = cur.next.next;
                    }
                }else {
                    cur = cur.next;
                }
            }
            return node.next;
        }
}
